<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>新闻展示页</title>
    </h:head>
    <h:body>
        <h:form>    
            <p:dock position="top"  >
                <p:menuitem value="返回" icon="image/back.png"  url="#" onclick="javascript :history.back(-1);"/>
               <p:menuitem value="主页" icon="image/home.png"  url="index.xhtml"/>
               <p:menuitem value="注册" icon="image/user.png"  url="util/register.xhtml"/>
               <p:menuitem value="关闭" icon="image/home.png"  url="#" onclick="window.close();"/>       
           </p:dock>

           <p:growl id="msgs" showDetail="true" />
           <p:fieldset legend="#{bodyBean.news.ntitle} " style="margin-bottom:20px" >
                   <h:panelGrid columns="2" cellpadding="10">

                       <h:outputText value="#{bodyBean.news.ncontext}" escape="false"/>
                   </h:panelGrid>
           </p:fieldset>

           <h3>评论区</h3>
           <p:outputPanel autoUpdate="true">
                <hr style="height:10px;border:none;border-top:10px groove skyblue;" />
                <br/>
               
                   <c:forEach items="#{bodyBean.pairDiscuss}" var="pair">
                       <h:panelGrid columns="2" cellpadding="5">
                            <h:outputText value="内容:" />
                            <h:outputText value="#{pair.discuss.dcontext}" style="font-weight: bold" escape="false"/>
                            <h:outputText value="#{pair.student.sname}" />
                            <h:outputText value="#{pair.discuss.dateString}" style=""/>
                            <hr/>
                            <br/>
                       </h:panelGrid>
                   </c:forEach>
              
           </p:outputPanel>
           
           <c:if test="#{userBean.student==null}">
                <p:outputLabel value="要想评论请先"/>
                <p:link value="登录" outcome="util/Login.xhtml" target="_blank">
                    <f:param name="url" value="#{request.servletPath}"/>
                    <f:param name="essay" value="#{param.get('essay')}"/>
                    <f:param name="index" value="#{param.get('index')}"/>
                </p:link>
           </c:if>
           
           <c:if test="#{userBean.student!=null}">
               <p:inputTextarea  value="#{userBean.discuss}" rows="5" cols="160" counter="display" maxlength="200" counterTemplate="{0} characters remaining." autoResize="false"  />
               <p:commandButton  value="Submit" actionListener="#{userBean.hanldComment}" update="text2"  oncomplete="PF('dlg').show()"  icon="ui-icon-disk" >                 
                    <f:param name="essay" value="#{param.get('essay')}"/>
                    <f:param name="index" value="#{param.get('index')}"/> 
               </p:commandButton>
               
                <p:dialog header="提交成功！" widgetVar="dlg" showEffect="fade" hideEffect="fade">
                     <h:outputText id="text2" value="#{userBean.discuss}" escape="false" />
                </p:dialog>
                <h:outputText id="display" />
           </c:if>
           
        </h:form>
    </h:body>
</html>

